package org.blogwu.learn.leetcode.二叉树;

public class CreateNode {
    static final int MAXIMUM_CAPACITY = 1 << 30;
    static final float DEFAULT_LOAD_FACTOR = 0.75f;

    public static void main(String[] args) {
        System.out.println(tableSizeFor(23));

        int s = 8;
        float ft = ((float) s / DEFAULT_LOAD_FACTOR) + 1.0F;
        System.out.println(ft);
        System.out.println((int) ft);
    }

    static final int tableSizeFor(int cap) {
        int n = cap - 1;
        n |= n >>> 1;
        n |= n >>> 2;
        n |= n >>> 4;
        n |= n >>> 8;
        n |= n >>> 16;
        return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
    }

}
